/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package neuralmusic.brain.module;

import java.util.List;

import neuralmusic.brain.ga.Token;
import neuralmusic.brain.ga.Type;

/**
 * 
 * @author pjl
 */
public class NeuronParams implements Cloneable {

	public float delayInSecs = 0;
	public float timeConstant = .01f;
	public float thresh = 1.0f;
	public float outputVal = 1.0f;
	public float floor = -0.5f;
	public float pulseDelta = 0.5f;

	public NeuronParams clone() {
		try {
			return (NeuronParams) super.clone();
		} catch (CloneNotSupportedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	public void tokenize(List<Token> prams) {
		prams.add(new Token(Type.D, delayInSecs));
		prams.add(new Token(Type.T, thresh));
		prams.add(new Token(Type.O, outputVal));
		prams.add(new Token(Type.C, timeConstant));
		prams.add(new Token(Type.F, floor));
		prams.add(new Token(Type.P, pulseDelta));

	}

	public boolean parseToken(Token tok) {
		Type type = tok.type;
		Object data = tok.data;

		switch (type) {

		case D:
			delayInSecs = (Float) data;
			return true;
		case T:
			thresh = (Float) data;
			return true;
		case O:
			outputVal = (Float) data;
			return true;
		case C:
			timeConstant = (Float) data;
			return true;
		case P:
			pulseDelta = (Float) data;
			return true;
		case F:
			floor = (Float) data;
			return true;
		}
		
		return false;
	}
}
